<html>
<head><meta charset="utf-8"><title>generators and async fn · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/generators.20and.20async.20fn.html">generators and async fn</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="246000243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/generators%20and%20async%20fn/near/246000243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/generators.20and.20async.20fn.html#246000243">(Jul 14 2021 at 18:28)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="119031">@Esteban Küber</span> -- I have a question for you. I was thinking about generators and the question of their priority.</p>



<a name="246000257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/generators%20and%20async%20fn/near/246000257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/generators.20and.20async.20fn.html#246000257">(Jul 14 2021 at 18:29)</a>:</h4>
<p>I am overall a fan, and I think that having a better way to write iterators would be nice in general</p>



<a name="246000316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/generators%20and%20async%20fn/near/246000316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/generators.20and.20async.20fn.html#246000316">(Jul 14 2021 at 18:29)</a>:</h4>
<p>However, if we had async closures, you could at least get the equivalent of <code>std::iter::from_fn</code>, which I've found to be a very nice tool for writing sequential iterators</p>



<a name="246000363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/generators%20and%20async%20fn/near/246000363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/generators.20and.20async.20fn.html#246000363">(Jul 14 2021 at 18:29)</a>:</h4>
<p>I guess my main thought is, we should evaluate how much that changes (if anything)</p>



<a name="246000429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/generators%20and%20async%20fn/near/246000429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/generators.20and.20async.20fn.html#246000429">(Jul 14 2021 at 18:30)</a>:</h4>
<p>Fair... I'll make some mockups</p>



<a name="246000504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/generators%20and%20async%20fn/near/246000504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/generators.20and.20async.20fn.html#246000504">(Jul 14 2021 at 18:30)</a>:</h4>
<p>I expect that there would still be some value on generators even with async closures and async_iter::from_fn</p>



<a name="246002472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/generators%20and%20async%20fn/near/246002472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/generators.20and.20async.20fn.html#246002472">(Jul 14 2021 at 18:47)</a>:</h4>
<p>It seems clear there would be</p>



<a name="246002579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/generators%20and%20async%20fn/near/246002579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/generators.20and.20async.20fn.html#246002579">(Jul 14 2021 at 18:48)</a>:</h4>
<p>Both would achieve the goal of not having to encounter as many complex details, but writing <code>std::iter::from_fn</code> is not always easy.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>